<?php
    require_once "../../config.php";
    require_once "../../functions.php";
    //连接数据库
    $connect = connect();
    //sql语句
    $sql = "SELECT * from categories";
    //执行sql语句,并返回一个二维数组
    $resultArr = querySelect($connect,$sql);
    //返回数据
    // print_r($resultArr);
    $response = ["code"=>0,"msg"=>"操作失败"];
    //如果查到数据
    if($resultArr){
        $response["code"] = 1;
        $response["msg"] = "操作成功";
        $response["data"] = $resultArr;
    }
    header("content-type:application/json;charset:utf8;");
    //以json数据返回
    echo json_encode($response);

?>